<?php
/**
 * Praized template functions/helpers/tags: individual merchant action related functions
 * 
 * @version 1.5
 * @package PraizedCommunity
 * @subpackage TemplateFunctions
 * @author Stephane Daury
 * @copyright Praized Media, Inc. <http://praizedmedia.com/>
 * @license Apache License, Version 2.0 <http://www.apache.org/licenses/LICENSE-2.0>
 */

/**
 * Template function: Tests if the current merchant truly has an action
 *
 * @return boolean
 * @since 1.5
 */
function pzdc_has_action() {
    global $PraizedCommunity;
    return $PraizedCommunity->tpt_has_action();
}

/**
 * Template function: Current action summary (defaults to echo)
 *
 * @param boolean $echo Defines if the output should be echoed or simpy returned, defaults to TRUE
 * @return string
 * @since 1.5
 */
function pzdc_action_summary($echo = TRUE) {
    global $PraizedCommunity;
    return $PraizedCommunity->tpt_attribute_helper('action', 'summary', $echo);
}

/**
 * Template function: Current action creation date (defaults to echo)
 *
 * @param boolean $echo Defines if the output should be echoed or simpy returned
 * @param string $format strftime type format string
 * @return string
 * @since 1.5
 */
function pzdc_action_created_at($echo = TRUE, $format = NULL) {
    global $PraizedCommunity;
    $out = $PraizedCommunity->tpt_attribute_helper('action', 'created_at', FALSE);
    if ( strstr($format, '%'))
        $out = pzdc_date($out, $format);
    if ( $echo )
        echo $out;
    return $out;
}

/**
 * Template function: Current action type (defaults to echo)
 *
 * @param boolean $echo Defines if the output should be echoed or simpy returned, defaults to TRUE
 * @return string
 * @since 1.5
 */
function pzdc_action_type($echo = TRUE) {
    global $PraizedCommunity;
    return $PraizedCommunity->tpt_attribute_helper('action', 'action_type->type_name', $echo);
}

/**
 * Template function: Current action comment body (defaults to echo)
 *
 * @param boolean $echo Defines if the output should be echoed or simpy returned, defaults to TRUE
 * @return string
 * @since 1.5
 */
function pzdc_action_comment_body($echo = TRUE) {
    global $PraizedCommunity;
    $out = $PraizedCommunity->tpt_attribute_helper('action', 'targets', FALSE);
    $body = $out[0]->comment->comment;
    if ( $echo )
        echo $body;
    return $body;
}
?>